package gui;

import gui.menu.HighscoreMenu;
import gui.menu.MainMenu;
import gui.menu.OptionsMenu;
import gui.menu.SelectPlayersMenu;

import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Font;

import javax.swing.JFrame;
import javax.swing.JPanel;

import control.Control;


public class GUI extends JFrame{
	
	public static final Color BGMENU = Color.BLACK;
	public static final Color BGGAME = Color.BLACK;
	public static final Color FGMENU = Color.BLUE;
	public static final Font font = new Font("Calibri", 1, 30);
	
	private JPanel menus;
	private Control control;
	
	public MainMenu mainmenu;
	public OptionsMenu optionsmenu;
	public GamePanel gamepanel;
	public SelectPlayersMenu playeroptions;
	public HighscoreMenu highscoremenu;
	
	CardLayout cl;
	
	public JPanel akt;
	
	public GUI(Control c){
		super();
		this.setBackground(Color.GREEN);
		control = c;
		
		//initialise the menus
		mainmenu = new MainMenu(control.mainManager, BGMENU);
		optionsmenu = new OptionsMenu(control.optionsManager, BGMENU, control.getOptions());
		gamepanel = new GamePanel();
		playeroptions = new SelectPlayersMenu();
		highscoremenu = new HighscoreMenu(control.getHighscores(), control.highscoreManager);
		
		cl = new CardLayout();
		menus = new JPanel(cl);
		
		initGUI();
	}
	
	public void initGUI(){
		
		this.getContentPane().removeAll();
		menus.removeAll();
		
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		
		this.getContentPane().setLayout(new BorderLayout());
		
		
		//add all menus to the CardLayout panel

		menus.add(mainmenu, "MainMenu");
		menus.add(optionsmenu,"OptionsMenu");
		menus.add(gamepanel,"GamePanel");
		menus.add(playeroptions,"PlayerOptions");
		menus.add(highscoremenu, "HighscoreMenu");
	
		this.getContentPane().add(menus, BorderLayout.CENTER);

		cl.show(menus, "MainMenu");
		
		gamepanel.setBackground(BGGAME);
		pack();
		setExtendedState(JFrame.MAXIMIZED_BOTH);
		
		setLocationRelativeTo(null);
		setVisible(true);
	}

	
	public JPanel getMenus(){
		return menus;
	}
	
	
	public MainMenu getMainMenu(){
		return mainmenu;
	}
	
	public OptionsMenu getOptionsMenu(){
		return optionsmenu;
	}

	public void showMenu(String s){
		cl.show(menus, s);
	}
}
